﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SuperX.Common
{
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class WebApiAttribute : Attribute
    {
        /// <summary>
        /// 简述
        /// </summary>
        public string Summary { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnable { get; set; }

        /// <summary>
        /// 名字
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 参数信息
        /// </summary>
        public string[] Params { get; set; }

        /// <summary>
        /// 返回值信息
        /// </summary>
        public string Returns { get; set; }

        /// <summary>
        /// 默认函数
        /// </summary>
        public WebApiAttribute()
        {
            IsEnable = true;
        }

        /// <summary>
        /// 是否显示这个接口
        /// </summary>
        /// <param name="visible"></param>
        public WebApiAttribute(bool visible)
        {
            IsEnable = visible;
        }

        /// <summary>
        /// 添加了接口说明以及字段说明
        /// </summary>
        /// <param name="summary">概述</param>
        public WebApiAttribute(string summary, string @params)
        {
            IsEnable = true;
            Summary = summary;
            Params = @params.Split(',');
        }

        /// <summary>
        /// 添加了接口说明以及字段说明
        /// </summary>
        /// <param name="summary">概述</param>
        public WebApiAttribute(string summary, string @params, string returns)
        {
            IsEnable = true;
            Summary = summary;
            Params = @params.Split(',');
            Returns = returns;
        }
    }
}
